import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:sample2/helper/app_helper.dart';

class HomeContentLast extends StatelessWidget {
  const HomeContentLast({super.key});
  @override
  Widget build(BuildContext context) {
    return Center(
      // Center is a layout widget. It takes a single child and positions it
      // in the middle of the parent.
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          TextButton(
              onPressed: () async {
                redirectWebPage() async {
                  Uri uri = Uri.parse("${AppHelper.shared.getBkDomainName()}/flutter?username=1");
                  if (!await launchUrl(uri)) {
                    throw "Could not launch $uri";
                  }
                }

                try {
                  if (!kIsWeb) {
                    Navigator.pushNamed(context, "/webview");
                  } else {
                    redirectWebPage();
                  }
                } catch (e) {
                  redirectWebPage();
                }
              },
              child: const Text("WebView")),
          TextButton(
              onPressed: () {
                Navigator.pushNamed(context, "/mypopup");
              },
              child: const Text("popup Page")),
          Text(
            'large title',
            style: Theme.of(context).textTheme.titleLarge,
          ),
          Image.asset(
            "images/a_dot_ham.jpeg",
            fit: BoxFit.fitWidth,
          )
        ],
      ),
    );
  }
}
